package cn.vendcommon.com.entity.enums;

import lombok.Getter;
import java.util.concurrent.TimeUnit;

@Getter
public enum CommonRedisKey {

    USER_TOKEN("userToken:", TimeUnit.MINUTES, 30);

    private final String prefix;
    private final TimeUnit unit;
    private final int expireTime;

    CommonRedisKey(String prefix, TimeUnit unit, int expireTime) {
        this.prefix = prefix;
        this.unit = unit;
        this.expireTime = expireTime;
    }

    /**
     * 获取实际的 Redis Key
     * @param key 业务传入的 key
     * @return 拼接后的 redis key
     */
    public String getRealKey(String key) {
        return this.prefix + key;
    }
}
